#region Imported Namespaces
using System;
using System.Collections.Specialized;
using System.Data;
using System.Web.UI.WebControls;

using PHSRAG.Insight21.Context;
using BO = PHSRAG.Insight21.BusinessObjects;
using DataAccess = PHSRAG.Utility.DataAccess;
using ICachePolicy = PHSRAG.Insight21.Policy.ICachePolicy;
using GenerateKey = PHSRAG.Insight21.BusinessObjects.ModuleKey;
#endregion

namespace PHSRAG.Insight21.SearchContext
{
	/// <summary>
	/// Summary description for BudgetBuilderSeachContext.
	/// </summary>
	public class BudgetBuilderSearchContext: SearchContext
	{
		#region Constants
		private static string budgetBuilderSearchContextKey = GenerateKey.MakeKey("budgetBuilderSearchContext_53F70C51-8AB8-4c29-B6E7-DBA10E77A4F7",GenerateKey.ClinicalTrials);
		private static string budgetBuilderSearchCriteriaKey = GenerateKey.MakeKey("budgetBuilderSearchCriteria_53F70C51-8AB8-4c29-B6E7-DBA10E77A4F7",GenerateKey.ClinicalTrials);
		#endregion

		#region Constructor
		/// <summary>
		/// Create an instance of the BudgetBuilderSearchContext class. Since this object does not hold any state 
		/// (other than whatever the base class holds), there is nothing to initialize.
		/// </summary>
		/// <param name="cachePolicy">Cache policy to use</param>
		public BudgetBuilderSearchContext(ICachePolicy cachePolicy)
			: base(cachePolicy)
		{
			DataContainer = new DataSet();
		}

		#endregion

		#region Class Methods
		/// <summary>
		/// Get the cached instance of the BudgetBuilderSeachContext object (if any).
		/// </summary>
		/// <returns>Reference to the cached object or null if never cached</returns>
		public static string CacheKey
		{
         get
         {
            return budgetBuilderSearchContextKey;
         }
		}
		#endregion

		#region Overrides

		/// <summary>
		/// Adds the BudgetBuilderSearchContext object to the cache
		/// </summary>
		public override void Cache()
		{
			CachePolicy.Cache(budgetBuilderSearchContextKey, this);
		}

		/// <summary>
		/// Removes the BudgetBuilderSearchContext object from the cache
		/// </summary>
		public override void UnCache()
		{
			CachePolicy.UnCache(budgetBuilderSearchContextKey);
		}

		/// <summary>
		/// Load budget builder search data for any drop-down lists into the data container.
		/// Currently, does nothing since there are no drop-down lists
		/// </summary>
		/// <param name="connectionString">Connection string to the database</param>
		/// <param name="args">Arugments to the invoked stored procedure</param>
		public override void Load(string connectionString, params object[] args)
		{

		}

		#endregion

		#region ISearchContext Members
		/// <summary>
		/// Get/Set the search criteria using the prevailing cache policy (specified during object construction).
		/// </summary>
		public SearchCriteria SearchCriteria
		{
			get { return CachePolicy.GetCachedObject(budgetBuilderSearchCriteriaKey) as SearchCriteria; }
			set	{ CachePolicy.Cache(budgetBuilderSearchCriteriaKey, value); }
		}

		/// <summary>
		/// Reset the internal search state.
		/// </summary>
		public void Reset()
		{
			DataContainer.Reset();
			CachePolicy.UnCache(budgetBuilderSearchCriteriaKey);
		}
		#endregion
	}
}
